/**
 * COPYRIGHT HangZhou Trustway Technology Company Limited
 * All right reserved.
 */
package com.robam.cloud.authcenter.feigner;

import com.robam.cloud.authcenter.service.MediaService;
import com.robam.cloud.common.bean.restful.entity.RespMsg;
import com.robam.cloud.log.annotation.OperationLogRecord;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @Description
 * @Author 薛铁琪 微信支付宝等三方文件下载
 * @CreateTime 2020-08-19 16:38
 * @Version 1.0
 */
@RestController
@RequestMapping("/feign/authCenter")
public class FileFeiger {
    @Autowired
    MediaService mediaService;
    @Autowired
    HttpServletRequest httpServletRequest;

    @ApiOperation(
            value = "三方文件下载",
            notes = "三方文件下载")
    @RequestMapping(
            value = "/downloadFile",
            method = RequestMethod.GET)
    @OperationLogRecord(
            describe = "三方文件下载",
            modularCode = "auth-feign-downloadFile",
            operationLevel = OperationLogRecord.OperationLevel.OTHER)
    public RespMsg<String> downloadFile(@RequestParam(value = "serverId") String serverId) {
        return RespMsg.success(mediaService.getMediaUrl(serverId, httpServletRequest));
    }
}
